extern int16_t desired_vel_x;
extern int16_t desired_vel_y;
extern int16_t desired_vel_z;
extern int16_t desired_yaw_rate;
extern int8_t autocontrol_flag;

extern uint8_t mession_state;
extern uint8_t electromagnet_state;
extern uint8_t son_plane_state;
typedef struct
{
    float Input_Butter[3];
    float Output_Butter[3];
} ButterworthFilter_BufferData;
typedef struct
{
    float a[3];
    float b[3];
} ButterworthFilter_Parameter;
typedef struct
{
  float k;//滤波系数
  float lVal;//上次计算值
}rcPara_t;
typedef struct
{
    bool ErrorLimit_Flag;         //误差限幅标志
    bool IntegralSeparation_Flag; //积分分离标志
    bool IntegralLimit_Flag;      //积分限幅标志

    float Loop_Time;                                       //控制步长
    // ButterworthFilter_BufferData ButterworthFilter_Buffer; //巴特沃斯滤波器缓冲数据

    float Kp; //PID控制参数-比例
    float Ki; //PID控制参数-积分
    float Kd; //PID控制参数-微分


    float Error;         //误差
    // double Error_LPF;     //经过低通滤波后的误差
    float LastError;     //上次误差
    // double LastError_LPF; //经过低通滤波后的上次误差
    float Error_Max;     //误差限幅值

    float Integrate;                //积分值
    float Integrate_Max;            //积分限幅值
    float IntegralSeparation_Error = 0.2; //积分分离误差阈值

    float Differential;     //微分量
    // double Differential_LPF; //经过低通滤波后的微分量

    float Output;       //控制输出量
    float Output_Limit; //控制输出限幅
    float Output_deadzone;
} PID_Controller;

// void PID_Init(PID_Controller *PID, float kp, float ki, float kd, float output_limit);
// double PID_Control(PID_Controller *PID, float desire_value, float actual_value);
void IARC_task_init();
void IARC_task(groundbase_cmd_t* para);
float rcLfFiter(rcPara_t *rcPara, float val);